use std::ptr::NonNull;


pub trait UnSafeAsMut {
    fn to_mut(&self) -> &mut Self;
}

impl<T> UnSafeAsMut for T {

    #[inline(always)]
    fn to_mut(&self) -> &mut Self {
        unsafe  {
            NonNull::new_unchecked((self as *const T) as *mut T).as_mut()
        }
    }
}


pub fn new_buf(len: usize) -> Box<[u8]> {
    unsafe {
        let mut buf = Vec::with_capacity(len);
        buf.set_len(len);
        buf.into_boxed_slice()
    }
}

